import * as actionTypes from "./actionTypes";
import { fromJS } from "immutable"; //把数据转为immutable对象，使用这个使用更要使用gget方法，使用set方法去变更state内容
const defaultState = fromJS({
  focused: false, //input聚焦
  enter: false,
  list: [], //历史记录
  page: 0,
  pageSize: 6,
  totalPage: 0,
});

// 导出一个纯函数
export default (state = defaultState, action) => {
  switch (action.type) {
    case actionTypes.serch_blur:
      return state.set("focused", false);

    case actionTypes.serch_fouce:
      return state.set("focused", true);
    case actionTypes.history_list:
      return state.set("list", action.data).set("totalPage", action.totalPage);

    case actionTypes.mouseEnter_type:
      console.log("acti", action.data);
      return state.set("enter", action.data);
    case actionTypes.getOtherPage_type:
      return state.set("page", action.data);
    default:
      break;
  }
  return state;
};
